<template>
  <div>
    <f-form ref='customBondForm' :action='api.payment' :form-key='this.formItem.paymentId' handler-name='customBondPaymentSaveHandler' :file-ids='fileIds'>
      <f-form-item label="部门" name="deptId" type="select" :show-search='true' :data="api.dept.list" valueKey="deptId" :value="formItem.deptId" :required="true" label-key="deptName" />
      <f-form-item label="收款金额" type="number" name="amount" dataType="number" :value="formItem.amount" :precision="4" :required="true" />
      <f-form-item label="收款账户" ref="bank" type="select" name="bankId" :value="formItem.bankId" :data="api.bank.list" valueKey="bankId" label-key="bankName" :required="true" />
      <f-form-item label="收款日期" type="date" name="amountDate" :required="true" :value="formItem.amountDate"/>
      <f-form-item label='附件' type='upload' name='jsImage' :value='formItem.jsImage' value-type='json' :file-max='50' @uploadSuccess='uploadSuccess' />
      <f-form-item label='备注' name='remark' :value='formItem.remark' />
    </f-form>
  </div>
</template>

<script>
import api from "../js/api"

export default {
  name: "CustomBondForm",
  components: {},
  data() {
    let me = this
    //操作按钮
    let operator = []
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {},
      fileIds: [],//上传文件ID
      loaded: false,
      bankInfo: {},
      bankModal:false,
      params1: {
        supplierId: "",
        bankType: 1
      },
      supplierBankForm:{},
      formItem: this.getFormItem()

    }
  },
  created() {
  },
  methods: {
    getFormItem() {
      return {
        orderId: "",
        supplierBond: 0,
        bankId: "",
        supplierId: "",
        title: ""
      }
    },
    setData(data) {
      if (data && data.orderId) {
        this.formItem = data

      }
    },
    handleCancel() {
      this.bankModal = false
      this.$refs["bank"].initData({ supplierId: this.formItem.supplierId, bankType: 1 })
    },
    handleSubmit() {
      let params = {
        orderId: this.formItem.orderId,
        amount: this.formItem.supplierBond,
        supplierId: this.formItem.supplierId,
        orderDetailsId:this.formItem.orderDetailsId,
        amountType: "SupplierBond"
      }
      this.$refs["customBondForm"].submit(params, this.handleSuccess)
    },
    //文件上传回调
    uploadSuccess(fileUrl, files, fileIds) {
      this.fileIds = fileIds
    },
    handleSuccess() {
      this.$emit("closeDrawer", false)
    }
  }
}
</script>